And so now we have our shop where we could buy stuff with our points.
Then we have the stuff.
But if we leave the game or if we die, we lose the stuff.
Today we're going to fix that.
So wait for it.
Let me play the game.
I had already bought a pistol and a lemon and now look at that.
I got my pistol.
I got my lemon if I die.
Yeah.
Wait for it.
There we go.
We got it again.
So I do just put it in the backpack when we reset.
But that's fine.
You could just pick it up.
At least you have your stuff.
And if we look at our view output, we don't see any errors.
That's what I like to see.
So let's go ahead and get started on that.
I have my zombie game open and now I need to add the ability to store the things that I bought in my
shop to my data store so that when I die and come back, or if I leave the game and come back, I still
have my items.
Now I could put this storage stuff on my player like I did with Daily Streak, but the items are going
to be more sophisticated.
We're going to have guns, we're going to keep track of ammo.
We may have reload speed changes, We might have a fabulous lemon that has teleportation powers, Cool
stuff like that.
More than just one number, like a daily streak.
So we're going to need an equipment storage manager of some type.
Let's go to our server script service, hit the plus, add a module script, and I'm going to call this
equip storage utils.
Let's change this default module name to equipment.
I'll just say equip utils.
It doesn't have to be the same name as the file name, but if you change it here control C, you have
to change it here.
And these two have to match the the declaration and the return.
All right.
We're going to need another table in here, and I'll just define this locally, local equipment table.
And what do you think that's going to do?
Well, let's put a note so we don't have to guess.
I'm going to say data table that has the equipment info for each player, each player currently playing.
Right.
And we're going to need a few functions.
Let's put a note.
So first thing I think I want to handle is called when purchase.
So we're going to purchase an item and we're going to we're going to store that item data for the player
that purchased the item.
Let's do this function because we're going to we're going to call this from our shop stuff, right?
Our server side shop script.
I'll get this equip utils.
There we go.
Oh my gosh.
Utils colon.
Add item to player's inventory.
We're going to have the player and then we're going to have an item.
How do I spell item?
There he goes.
Item info table.
So we're going to have a table that we're adding to the table, right?
We may have a gun.
We might have six bullets, we might have damage information, we might have a lot of stuff going on
in this equipment that we bought.
So we want to capture all of that information.
And now I'm going to put a comment for my next function.
I'm not filling out these functions yet.
I'm going to get to them.
And this one will be initialized when the player enters the game.
Right.
So I'll say called on initialized initialization.
I spell that right data called on initialization data.
I'll just say initialization when player enters the game.
Right.
So somebody entered the game.
We're going to go to the data store, we're going to get this equipment information, we're going to
store it in our table.
We'll say, function, equip, utils.
I'm going to call this update player.
With DB info.
All right.
So we'll have all of the equipment data is going to be in here.
This is when they're entering the game.
Anything we save off from here, we haven't done that yet.
From here is going to be put into this data.
We're going to parse it out right here.
Right.
That's going to be the meat of the of the script.
All right.
We're going to need what else are we going to need?
Are we're going to put the data inside the table, but then we have to actually equip the player.
Right.
So we'll say.
Equip player data is whoops, data is already in table, but player doesn't have it.
All right, so we've got our function here and then we'll do equip utils and I'll just call this equip
player.
I make sense.
Oh, we'll pass the player in.
We'll be able to find all the information is already in our equipment table.
And one last very easy function, Right?
I need to remove the player data from this table when they leave the game.
Else it's just going to get bigger and bigger and bigger until we we restart the server.
So I'll say when player is removed from game, remove info from table.
Now you wouldn't even notice this growth unless you had a very popular game.
If you had thousands of people playing and the server was running for a period of time, you start bogging
it down.
Right?
But you wouldn't notice that you wouldn't notice this right away.
I'll say equip utils remove player.
So this is going to remove the data for the player from our table.
That's pretty cool.
All right, now we can go ahead and start populating this out a little bit and seeing where we're going
to call this stuff.